package com.itheima.多线程.基础;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class Demo8 {
    public static void main(String[] args) {
        MyCallable mc = new MyCallable();
        FutureTask<String> ft1 = new FutureTask<>(mc);
        FutureTask<String> ft2 = new FutureTask<>(mc);
        Thread th1 = new Thread(ft1, "一");
        Thread th2 = new Thread(ft2, "二");
        System.out.println(th1.getPriority());
        System.out.println(th2.getPriority());
        System.out.println("============================");
        th1.setPriority(10);
        th2.setPriority(1);
        System.out.println(th1.getPriority());
        System.out.println(th2.getPriority());
        th1.start();
        th2.start();
    }
}

class MyCallable implements Callable<String> {
    @Override
    public String call() throws Exception {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName() + "..." + i);
        }
        return "成功";
    }
}